home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <string.h>
- #include <stdio.h>
- #include <Xm/Xm.h>
- #include <stdlib.h>
- #include <Xm/PushB.h>
- #include <Xm/MenuShell.h>
- #include <Xm/CascadeB.h>
- #include <Xm/RowColumn.h>
- #include <Xm/MainW.h>
- #include <Xm/Form.h>
- #include <Xm/DialogS.h>
- #include <Xm/XmStrDefs.h>
- #include <X11/Shell.h>
- #include <Xm/MwmUtil.h>
- #include "includes/ColorC.h"
-
- Widget Mainwin; /* Main window widget - parent to all */
- Widget myDialog; /* dialog widget for color chooser */
-
-
- /*
- **
- ** Call back for menu item 1 on Action menu
- **
- */
- void pbutton1_action(Widget w, XtPointer arg_int, XmAnyCallbackStruct *call_data)
- {
- printf("Pushbutton 1 was selected\n");
- }
-
-
- /*
- **
- ** Call back for quit button on menu bar
- **
- */
- void quit_action(Widget w, XtPointer arg_int, XmAnyCallbackStruct *call_data)
- {
- exit(0);
- }
-
- /*
- **
- ** Create the popup dialog for the color chooser
- ** widget.
- **
- */
- void create_myDialog()
- {
- Widget colorchooser;
-
- myDialog = XtVaCreatePopupShell( "eventList",
- xmDialogShellWidgetClass, Mainwin,
- XmNtitle, "ColorChooser Sample",
- XmNminHeight, 400,
- XmNminWidth, 500,
- XmNallowShellResize, TRUE,
- NULL );
-
- XtVaSetValues(myDialog, XmNx, 500, XmNy, 500, NULL);
-
- colorchooser = XtVaCreateManagedWidget("colorchooser",
- sgColorChooserWidgetClass, myDialog,
- NULL);
- }
-
- /*
- **
- ** Call back for menu item 1 on Action menu - invoke chooser
- **
- */
- void pbutton2_action(Widget w, XtPointer arg_int, XmAnyCallbackStruct *call_data)
- {
- void create_myDialog();
-
- /* When invoked, create a new color chooser popup */
- create_myDialog();
- }
-
- /*
- **
- ** main
- **
- */
- main(argc, argv)
- int argc;
- char *argv[];
- {
- Arg args[10];
- int argcnt=0;
- Widget button;
- Widget pulldown;
- Widget menubar;
- Widget pbutton1, pbutton2;
- Widget quit;
- Window root;
- void pbutton1_action();
- void pbutton2_action();
- void quit_action();
- Widget pulldownshell;
- XEvent queue_event;
- XtAppContext appContext;
- int screen;
- Display *dpy;
- Widget TopLevel;
-
-
- /* Initialize the Xt toolkit */
- XtToolkitInitialize();
-
- /* Create an application context */
- appContext = XtCreateApplicationContext();
-
- /* Open a display */
- dpy = XtOpenDisplay(appContext, NULL, NULL, "Test", NULL ,0, &argc, (String *)argv);
-
- /* get the screen id 'screen */
- screen = DefaultScreen(dpy);
-
- /* get the root window 'root' */
- root = RootWindow(dpy, screen);
-
- /* Create the top level application shell */
- TopLevel = XtAppCreateShell(NULL, "Color Chooser Test", applicationShellWidgetClass, dpy, args, 0);
-
- XSync(dpy, TRUE);
-
- /* Create the main window widget */
- Mainwin = XtVaCreateManagedWidget( "x1", xmMainWindowWidgetClass,
- TopLevel, XmNwidth, 300, XmNheight, 100,
- XmNresizePolicy, XmRESIZE_NONE, NULL);
-
- /* Create a menu bar */
- menubar = XtVaCreateManagedWidget( "menubar", xmRowColumnWidgetClass,
- Mainwin,
- XmNrowColumnType, XmMENU_BAR,
- XmNwidth, 1000, XmNheight, 60, NULL);
-
- /* create the pulldown shell for the menu */
- pulldownshell = XtVaCreateWidget("pulldownshell",
- xmMenuShellWidgetClass, Mainwin,
- XmNwidth, 1,
- XmNheight, 1,
- XmNallowShellResize, TRUE,
- XmNoverrideRedirect, TRUE,
- NULL );
-
- /* Create the rowColumn for the menu */
- pulldown = XtVaCreateWidget( "m1", xmRowColumnWidgetClass,
- pulldownshell,
- XmNrowColumnType, XmMENU_PULLDOWN,
- XmNheight, 60, NULL);
-
-
- /* Create the cascade button for the menu bar */
- button = XtVaCreateManagedWidget( "Actions", xmCascadeButtonWidgetClass,
- menubar,
- XmNsubMenuId, pulldown,
- NULL);
-
- /* Add a quit button to the menu bar */
- quit = XtVaCreateManagedWidget( "Quit", xmCascadeButtonWidgetClass,
- menubar,
- XmNlabelString,
- (XmString *) XmStringCreate("Quit", XmFONTLIST_DEFAULT_TAG),
- NULL);
-
- /* Callback for the quit button */
- XtAddCallback(quit, XmNactivateCallback, quit_action, NULL);
-
- /* Add item 1 on the menu */
- pbutton1 = XtVaCreateManagedWidget("selection 1",
- xmPushButtonWidgetClass, pulldown,
- XmNaccelerator, "Ctrl<Key>n",
- XmNacceleratorText,
- (XmString *) XmStringCreate("Ctrl+N", XmFONTLIST_DEFAULT_TAG),
- XmNlabelString,
- (XmString *) XmStringCreate("Prints Test Text", XmFONTLIST_DEFAULT_TAG),
- NULL);
-
- /* Callback for the first menu item */
- XtAddCallback(pbutton1, XmNactivateCallback, pbutton1_action, NULL);
-
- /* Add item 2 on the menu, invoke color chooser */
- pbutton2 = XtVaCreateManagedWidget("selection 2",
- xmPushButtonWidgetClass, pulldown,
- XmNaccelerator, "Ctrl<Key>m",
- XmNacceleratorText,
- (XmString *) XmStringCreate("Ctrl+M", XmFONTLIST_DEFAULT_TAG),
- XmNlabelString,
- (XmString *) XmStringCreate("Color Chooser", XmFONTLIST_DEFAULT_TAG),
- NULL);
-
- /* Callback for the second menu item, invoke color chooser */
- XtAddCallback(pbutton2, XmNactivateCallback, pbutton2_action, NULL);
-
- /* Realize the top level widget */
- XtRealizeWidget(TopLevel);
-
- /* Main loop */
- while(True) {
- XtAppNextEvent(appContext, &queue_event);
- XtDispatchEvent(&queue_event);
- }
- }
-